package ynu.edu.controller;


import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import ynu.edu.entity.User;

/**
 * 用户控制器
 * 提供用户相关服务接口
 */
@RestController
@RequestMapping("/user")
public class UserController {
    
    /**
     * 根据用户ID获取用户基本信息
     * @param userId 用户ID
     * @return 用户基本信息
     */
    @GetMapping("/getUserById/{userId}")
    public User GetUserById(@PathVariable("userId") Integer userId){
        User user = new User();
        user.setUserId(userId);
        user.setUserName("小明 from 11000");
        user.setPassWord("123456");
        return user;
    }
    
    /**
     * 根据用户ID获取用户详细信息
     * @param userId 用户ID
     * @return 用户详细信息
     */
    @GetMapping("/getUserDetail/{userId}")
    public User getUserDetail(@PathVariable("userId") Integer userId){
        // 模拟获取详细信息的延迟
        try {
            Thread.sleep(100);
        } catch (InterruptedException e) {
            Thread.currentThread().interrupt();
        }
        
        User user = new User();
        user.setUserId(userId);
        user.setUserName("小明详细信息 from 11000");
        user.setPassWord("详细密码123456");
        return user;
    }
}
